<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
    <script>
        function fenye(cpage){
            $("[name='cpage']").val(cpage);
            $("form").submit();
        }

        function del(id){
            $.ajax({
                url:"del.do",
                type:"post",
                dataType:"json",
                data:{"id":id},
                success:function (object){
                    if(object>0){
                        location="list.do";
                    }
                }
            })
        }

        function cz(id){
            $.ajax({
                url:"cz.do",
                type:"post",
                dataType:"json",
                data:{"id":id},
                success:function (object){
                    if(object>0){
                        location="list.do";
                    }
                }
            })
        }
    </script>
</head>

<body>

    <form action="/list.do" method="post">
        <input type="hidden" name="cpage" >
        <input type="text" name="mohu1" value="${map.mohu1}">
        <select name="mohu2">
            <option value="">请选择</option>
            <option value="0" ${map.mohu2==0?'selected':''}>待租</option>
            <option value="1" ${map.mohu2==1?'selected':''} >已租</option>
        </select>
        <input type="submit">
    </form>
    <table>
        <tr>
            <th>编号</th>
            <th>小区名称</th>
            <th>单元</th>
            <th>门牌</th>
            <th>实景图</th>
            <th>状态</th>
            <th>挂牌时间</th>
            <th>出租时间</th>
            <th>户型</th>
            <th>面积</th>
            <th>
                <input type="button" value="添加" onclick="toadd()">
            </th>
        </tr>
        <c:forEach items="${pi.list}" var="h">
            <tr>
                <td>${h.id}</td>
                <td>${h.name}</td>
                <td>${h.building}</td>
                <td>${h.number}</td>
                <td>
                    <img src="${h.picture}" alt="无法展示">
                </td>
                <td>
                    ${h.status==1?'已租':'待租'}

                </td>
                <td>${h.listing_time}</td>
                <td>
                    ${h.status==1?h.rental_time:''}
                </td>
                <td>${h.cname}</td>
                <td>${h.square_meter}</td>
                <td>
                    <c:if test="${h.status==0}">
                        <input type="button" value="删除" onclick="del(${h.id})">
                        <input type="button" value="出租" onclick="cz(${h.id})">
                    </c:if>
                    <c:if test="${h.status==1}">
                        <input type="button" value="退租" onclick="cz(${h.id})">
                    </c:if>
                </td>
            </tr>
        </c:forEach>


        <tr>
            <td colspan="11">
                    第${pi.pageNum}页/共${pi.pages}页<br>
                <input type="button" value="首页" onclick="fenye(1)">
                <input type="button" value="上一页" onclick="fenye(${pi.isFirstPage?1:pi.prePage})">
<%--                <c:forEach items="${pi.navigatepageNums}" var="index">--%>
<%--                    <input type="button" value="${index}" onclick="fenye(${index})">--%>
<%--                </c:forEach>--%>
                <input type="button" value="下一页" onclick="fenye(${pi.isLastPage?pi.pages:pi.nextPage})">
                <input type="button" value="尾页" onclick="fenye(${pi.pages})">
            </td>
        </tr>
    </table>
</body>
</html>